package com.zmc.lostfound.file.controller;

import com.zmc.lostfound.common.utils.Result;
import com.zmc.lostfound.file.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ZMC
 * @description OSS对象存储文件管理接口
 * @email 2869581855@qq.com
 * @date 2023-07-05 15:30:10
 */
@RestController
@RequestMapping
@Api(value = "OSS对象存储文件管理接口", tags = "OSS对象存储文件管理接口")
public class FileController {

    private final FileService fileService;

    public FileController(FileService fileService) {
        this.fileService = fileService;
    }

    @ApiOperation("获取文件上传签名")
    @GetMapping("/getPolicy")
    public Result getPolicy() {
        return fileService.getPolicy();
    }

    @ApiOperation("上传图片或文档")
    @PostMapping("/upLoadFile")
    public Result upLoadFile(@RequestPart("file") MultipartFile file) {
        return fileService.upLoadFile(file);
    }

}
